#include <bits/stdc++.h>

using namespace std;
#define int long long

int n;
const int N = 350;
int a[N];

signed main()
{
    cin >> n;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    sort(a + 1 , a + 1 + n);
    int sum = 0;
    int l = 0 , r = n;
    while(l < r)
    {
        sum += (a[r] - a[l]) * (a[r] - a[l]);
        l++;
        sum += (a[r] - a[l]) * (a[r] - a[l]);
        r--;
    }
    cout << sum << endl;
    return 0;
}